package com.ferry.lock.lock;

import java.util.concurrent.TimeUnit;

/**
 * 锁接口
 * Created by daiyong
 */
public interface ILock {

	/**
	 * 最基本的锁
	 */
	void lock();

	/**
	 * 尝试锁
	 * @return
	 */
	boolean tryLock();

	/**
	 * 有限时间的尝试锁
	 * @param time
	 * @param timeUnit
	 * @return
	 */
	boolean tryLock(long time, TimeUnit timeUnit) throws InterruptedException;


	/**
	 * 可以被打断的锁
	 * @throws InterruptedException
	 */
	void lockInterruptibly() throws InterruptedException;

	/**
	 * 解锁
	 */
	void unLock();

	/**
	 * 锁名称
	 * @return
	 */
	String getName();


}
